/**
 * Created by zhangzhihao on 2016/12/06 11:00;
 */
var vm = new Vue({
	el : '#main',
	data : {
		taskId : App.getParam("taskId"),
		approve:{},
		approveData:{
			object:{},
		},
	},
	created : function() {
		this.queryTaskNodeApprove();
	},
	methods : {
		// 返回上一页的点击事件的函数
		goBtn : function() {
			// 不保留
			history.back(-1);
			// 保留
			// history.go(-1);
		},
		
		//通过
		approveNode:function(idx,_state){
			var _data = {};
			_data.taskId = $("#task_id"+idx).text();
			_data.nodeId = $("#node_id"+idx).text();
			if($("#"+idx).val() == ""){
				_data.approveMemo = "null";
			}else{
				_data.approveMemo = $("#"+idx).val();
			}
			_data.approveState = _state;
			_data.approveId = $("#approve_id"+idx).text();
			if(_data.approveId==''){
				_data.approveId=0;
			}
			
			App.ajax({
    			type : "POST",
    			url : App.getApiUrl("saveNodeApproveURL"),
    			data:_data,
    			success : function(data) {
    				var ret = data.ret;
    				if(ret=='00000'){ //审核成功
    					parent.showAlert(data.msg,function(){
                            		window.location.reload();
                        });
    					
    				}else{
    					parent.showAlert(data.msg);
    				}
    			}
    		});
    		
	    },
	    
        queryTaskNodeApprove:function(){
        	App.ajax({
    			type : "GET",
    			url : App.getApiUrl("queryTaskNodeApproveURL") + "?taskId="
    					+ this.taskId,
    			success : function(data) {
    				
    				vm.approve = data;
    			}
    		});
        },
		// 保存按钮的事件
		saveBtn : function() {
			
			//if (!this.userInfo.optName) {
			//	parent.showAlert("用户姓名不能为空！")
			//	return;
			//}
			//App.ajax({
			//	type : "POST",
				//url : App.getApiUrl("modifyUser"),
				//data : this.userInfo,
				//success : function(data) {
				//	parent.showAlert("修改用户成功");
				//}
			//});
		},
		xiazai:function(_fileId){
        	var _data = {'fileId':_fileId};
        	App.ajax({
    			type : "POST",
    			url : App.getApiUrl("downloadURL"),
        		data:_data,
    			success : function(data) {
    				var url = data.download_url;
    				window.location.href = url;
    			}
    		});
        	
        },
        fanhui:function(url,taskId){
            window.location.href = App.getBaseUrl() + url + "?taskId=" + taskId;
        },

        check:function(_fileId,taskId,checkid){
        	var _data = {'fileId':_fileId};
        	App.ajax({
    			type : "POST",
    			url : App.getApiUrl("downloadURL"),
        		data:_data,
    			success : function(data) {
    				var url = data.download_url;
    				window.location.href = App.getBaseUrl() + "sys/task/toexamine.html?taskId="+taskId+"&url="+url+"&checkid="+checkid;
    			}
    		});
        	
        },
	}
});